package ar.com.spsolutions.splilabrary.view.pages.book;

import org.apache.wicket.spring.injection.annot.SpringBean;

import ar.com.spsolutions.splibrary.book.Book;
import ar.com.spsolutions.splibrary.general.RoleConverterService.RolesEnum;
import ar.com.spsolutions.splibrary.services.dto.AbstractCRUDDTO;
import ar.com.spsolutions.splibrary.services.dto.CRUDBookDTO;
import ar.com.spsolutions.splilabrary.view.components.CRUDComponent;
import ar.com.spsolutions.splilabrary.view.version2.components.MainContainer;

/**
 * @author leezsi
 * 
 */
public class BookModificationComponent extends MainContainer {

	private static final long serialVersionUID = -5358192149014301652L;
	@SpringBean
	private CRUDBookDTO crudBookDTO;

	@Override
	protected void addComponents() {
		final CRUDComponent<Book> crudComponent = new CRUDComponent<Book>(
				"bookCRUD", "header", "footer", "data", this.getCrudBookDTO(),
				new String[] { "title:true", "publisher:true" });
		crudComponent.addText("title", "titleLabel", RolesEnum.ROLE_LIBRARIAN);
		crudComponent.addText("publisher", "publisherLabel",
				RolesEnum.ROLE_LIBRARIAN);
		crudComponent.addText("isbn", "isbnLabel", RolesEnum.ROLE_LIBRARIAN);
		crudComponent.addTextArea("description", "descriptionLabel",
				RolesEnum.ROLE_LIBRARIAN);
		crudComponent.addComboChoice("author", "authorLabel",
				RolesEnum.ROLE_LIBRARIAN);
		crudComponent.addPalette("categories", "categoriesLabel",
				RolesEnum.ROLE_LIBRARIAN);
		this.add(crudComponent);
	}

	private AbstractCRUDDTO<Book> getCrudBookDTO() {
		return this.crudBookDTO;
	}

	public void setCrudBookDTO(final CRUDBookDTO crudBookDTO) {
		this.crudBookDTO = crudBookDTO;
	}

}
